/*
*2018-7-4  by shangguanMr;
* */
//个人页面的action；
//引入对应的接口地址；
import {API_CONFIG} from "../../../services/api";
import {xFetch} from "../../../utils/xfetch";

export function creatToken(params) {
    return dispatch => {
        let url = API_CONFIG.host_first + "/token/api/issue";
        return xFetch(url, {
            method: "POST",
            body: params
        }).then((res) => {
            console.log("创建token成功==>>>", res);
            dispatch({type: "creatTokenSuccess", data: res});
            return Promise.resolve(res);
        }).catch((err) => {
            dispatch({type: "creatTokenError", msg: err});//或者全局去处理错误；
            console.log("创建token失败==>>>", err);
            return Promise.reject(err);
        })
    }
}

export function getETHAddress(params) {
    return dispatch => {
        let url = API_CONFIG.ekt_host + "/address/api/getETHAddress";
        return xFetch(url, {
            method: "GET",
            params: params
        }).then((res) => {
            console.log("请求ETH address成功==>>>", res);
            dispatch({type: "getETHAddressSuccess", data: res});
            return Promise.resolve(res);
        }).catch((err) => {
            dispatch({type: "getETHAddressError", msg: err});
            console.log("请求ETH address失败==>>>", err);
            return Promise.reject(err);
        })
    }
}
